import os
import cv2

def video_extract(video, out):
    for i in range(25*3):
        ret, frame = video.read()
        if ret:
            out.write(frame)
        else:
            break

def main():
    video_path = 'video_origin/4k_clip.mp4'
    output_path = 'video/4k_clip.mp4'
    fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')

    video = cv2.VideoCapture(video_path)
    image_width = int(video.get(cv2.CAP_PROP_FRAME_WIDTH))
    image_height = int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))
    fps = int(video.get(cv2.CAP_PROP_FPS))
    out = cv2.VideoWriter(output_path, fourcc, fps, (image_width, image_height))

    video_extract(video, out)
    out.release()


if __name__ == '__main__' :
    main()